/*     */ import java.awt.Color;
/*     */ import java.awt.Container;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Font;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Graphics2D;
/*     */ import java.awt.Insets;
/*     */ import java.awt.event.ActionEvent;
/*     */ import java.awt.event.ActionListener;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
/*     */ import java.awt.geom.Line2D.Double;
/*     */ import java.text.DecimalFormat;
/*     */ import java.util.Arrays;
/*     */ import java.util.List;
/*     */ import javax.swing.BorderFactory;
/*     */ import javax.swing.Box;
/*     */ import javax.swing.BoxLayout;
/*     */ import javax.swing.JButton;
/*     */ import javax.swing.JDialog;
/*     */ import javax.swing.JFrame;
/*     */ import javax.swing.JLabel;
/*     */ import javax.swing.JOptionPane;
/*     */ import javax.swing.JPanel;
/*     */ import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
/*     */ 
/*     */ public class StochChart extends JPanel
/*     */   implements MouseMotionListener, BBIInterface, ActionListener
/*     */ {
/*     */   private SymQuotes sq;
/*     */   private String sym;
/*  14 */   private float yScale = 1.0F;
/*  15 */   private float xScale = 1.0F;
/*     */   private double stickWidth;
/*     */   private float minVal;
/*     */   private float maxVal;
/*     */   private int parm1;
/*     */   private int parm2;
/*     */   private int parm3;
/*     */   private float[] fastK_parm1;
/*     */   private float[] low_parm1;
/*     */   private float[] high_parm1;
/*     */   private float[] fastK_parm1_parm2;
/*     */   private float[] slowD_parm3;
/*  24 */   private String m = "";
/*     */   private int mX;
/*     */   private int mY;
/*  26 */   public int noOfDays = 150;
/*     */   private double p1Y;
/*     */   private double p2Y;
/*     */   private double p11Y;
/*     */   private double p22Y;
/*     */   private double p0Y;
/*     */   private JTextField parm1TF;
/*     */   private JTextField parm2TF;
/*     */   private JTextField parm3TF;
/*     */   private JButton chgParmOk;
/*     */   private JButton chgParmCancel;
/*     */   private JButton defaultParms;
/*     */   private JDialog chgParmDialog;
/*  34 */   private DecimalFormat df = new DecimalFormat("0.00");
/*     */ 
/*  36 */   public String trend = "";
/*     */   public StochChart.EastPanel ep;
/*     */   private double refY;
/*     */   private double refX;
/* 574 */   private Font ssp10 = new Font("SansSerif", 0, 10);
/* 575 */   private Font ssp9 = new Font("SansSerif", 0, 9);
/* 576 */   private Line2D.Double refL1 = new Line2D.Double();
/* 577 */   private Line2D.Double refL2 = new Line2D.Double();
/* 578 */   private Line2D.Double gridY = new Line2D.Double();
/* 579 */   private Line2D.Double gridX = new Line2D.Double();
/* 580 */   private Line2D.Double yrefL1 = new Line2D.Double();
/* 581 */   private Line2D.Double yrefL2 = new Line2D.Double();
/*     */   private double yfactor;
/*     */   private double startPointX;
/*     */   private int dateRef;
/*     */   private int daysRef;
/* 586 */   private Line2D.Double l1 = new Line2D.Double();
/* 587 */   private Line2D.Double l2 = new Line2D.Double();
/*     */   private double x1;
/*     */   private double y1;
/*     */   private double x2;
/*     */   private double y2;
/*     */   private double u1;
/*     */   private double v1;
/*     */   private double u2;
/*     */   private double v2;
/*     */   private double a1;
/*     */   private double b1;
/*     */   private double a2;
/*     */   private double b2;
/*     */   private double xi;
/*     */   private double yi;
/* 589 */   private Line2D.Double uA = new Line2D.Double();
/* 590 */   private Line2D.Double lA = new Line2D.Double();
/* 591 */   private Line2D.Double hA = new Line2D.Double();
/*     */ 
/*     */   public StochChart(SymQuotes paramSymQuotes, int paramInt1, int paramInt2, int paramInt3)
/*     */   {
/*  41 */     this.sq = paramSymQuotes;
/*  42 */     this.sym = paramSymQuotes.sym;
/*     */ 
/*  44 */     this.fastK_parm1 = new float[paramSymQuotes.count];
/*  45 */     this.low_parm1 = new float[paramSymQuotes.count];
/*  46 */     this.high_parm1 = new float[paramSymQuotes.count];
/*  47 */     this.fastK_parm1_parm2 = new float[paramSymQuotes.count];
/*  48 */     this.slowD_parm3 = new float[paramSymQuotes.count];
/*     */ 
/*  50 */     this.parm1 = paramInt1;
/*  51 */     this.parm2 = paramInt2;
/*  52 */     this.parm3 = paramInt3;
/*     */ 
/*  54 */     if (this.noOfDays == 150)
/*  55 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/*  57 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/*  59 */     setBackground(Color.black);
/*  60 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */ 
/*  62 */     if (paramInt1 < paramSymQuotes.count) {
/*  63 */       lowHigh_parm1Finder();
/*  64 */       fastK_parm1Finder();
/*     */     }
/*     */ 
/*  67 */     if (paramInt1 + paramInt2 < paramSymQuotes.count) {
/*  68 */       fastK_parm1_parm2Finder();
/*     */     }
/*  70 */     if (paramInt1 + paramInt2 + paramInt3 < paramSymQuotes.count) {
/*  71 */       slowD_parm3Finder();
/*     */     }
/*  73 */     this.minVal = 0.0F;
/*  74 */     this.maxVal = 100.0F;
/*     */ 
/*  76 */     addMouseMotionListener(this);
/*     */ 
/*  78 */     if (this.fastK_parm1_parm2[(paramSymQuotes.count - 1)] >= this.slowD_parm3[(paramSymQuotes.count - 1)])
/*  79 */       this.trend = "Bullish";
/*     */     else {
/*  81 */       this.trend = "Bearish";
/*     */     }
/*  83 */     this.ep = new StochChart.EastPanel();
/*     */   }
/*     */ 
/*     */   public int getBBIdata(int paramInt)
/*     */   {
/*  90 */     if (this.fastK_parm1_parm2[paramInt] >= this.slowD_parm3[paramInt]) {
/*  91 */       return 1;
/*     */     }
/*  93 */     return 0;
/*     */   }
/*     */ 
/*     */   public void changeNoOfDays(int paramInt)
/*     */   {
/* 100 */     this.noOfDays = paramInt;
/*     */ 
/* 102 */     if (paramInt == 150)
/* 103 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 105 */       this.stickWidth = (1.5D * this.xScale);
/*     */   }
/*     */ 
/*     */   public void redrawChart(SymQuotes paramSymQuotes)
/*     */   {
/* 112 */     this.sq = paramSymQuotes;
/* 113 */     this.sym = paramSymQuotes.sym;
/*     */ 
/* 115 */     this.fastK_parm1 = new float[paramSymQuotes.count];
/* 116 */     this.low_parm1 = new float[paramSymQuotes.count];
/* 117 */     this.high_parm1 = new float[paramSymQuotes.count];
/* 118 */     this.fastK_parm1_parm2 = new float[paramSymQuotes.count];
/* 119 */     this.slowD_parm3 = new float[paramSymQuotes.count];
/*     */ 
/* 121 */     if (this.noOfDays == 150)
/* 122 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/* 124 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/* 126 */     if (this.parm1 < paramSymQuotes.count) {
/* 127 */       lowHigh_parm1Finder();
/* 128 */       fastK_parm1Finder();
/*     */     }
/*     */ 
/* 131 */     if (this.parm1 + this.parm2 < paramSymQuotes.count) {
/* 132 */       fastK_parm1_parm2Finder();
/*     */     }
/* 134 */     if (this.parm1 + this.parm2 + this.parm3 < paramSymQuotes.count) {
/* 135 */       slowD_parm3Finder();
/*     */     }
/* 137 */     this.minVal = 0.0F;
/* 138 */     this.maxVal = 100.0F;
/*     */ 
/* 140 */     if (this.fastK_parm1_parm2[(paramSymQuotes.count - 1)] >= this.slowD_parm3[(paramSymQuotes.count - 1)])
/* 141 */       this.trend = "Bullish";
/*     */     else {
/* 143 */       this.trend = "Bearish";
/*     */     }
/* 145 */     repaint();
/* 146 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void redrawChart()
/*     */   {
/* 153 */     if (this.parm1 < this.sq.count) {
/* 154 */       lowHigh_parm1Finder();
/* 155 */       fastK_parm1Finder();
/*     */     } else {
/* 157 */       Arrays.fill(this.low_parm1, 0.0F);
/* 158 */       Arrays.fill(this.high_parm1, 0.0F);
/* 159 */       Arrays.fill(this.fastK_parm1, 0.0F);
/*     */     }
/*     */ 
/* 162 */     if (this.parm1 + this.parm2 < this.sq.count)
/* 163 */       fastK_parm1_parm2Finder();
/*     */     else {
/* 165 */       Arrays.fill(this.fastK_parm1_parm2, 0.0F);
/*     */     }
/* 167 */     if (this.parm1 + this.parm2 + this.parm3 < this.sq.count)
/* 168 */       slowD_parm3Finder();
/*     */     else {
/* 170 */       Arrays.fill(this.slowD_parm3, 0.0F);
/*     */     }
/* 172 */     this.minVal = 0.0F;
/* 173 */     this.maxVal = 100.0F;
/*     */ 
/* 175 */     if (this.fastK_parm1_parm2[(this.sq.count - 1)] >= this.slowD_parm3[(this.sq.count - 1)])
/* 176 */       this.trend = "Bullish";
/*     */     else {
/* 178 */       this.trend = "Bearish";
/*     */     }
/* 180 */     repaint();
/* 181 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void mouseMoved(MouseEvent paramMouseEvent)
/*     */   {
/* 189 */     int j = 1;
/* 190 */     if ((paramMouseEvent.getX() >= 50) && (paramMouseEvent.getX() <= 750.0F * this.xScale + 50.0F) && (paramMouseEvent.getY() >= 10) && (paramMouseEvent.getY() <= this.yScale * 100.0F + 10.0F))
/*     */     {
/* 192 */       int i = (int)((750.0F * this.xScale - (paramMouseEvent.getX() - 50) - this.stickWidth / 2.0D) / (this.stickWidth + 1.0F * this.xScale));
/*     */ 
/* 194 */       if (this.sq.count - 1 >= i)
/*     */       {
/* 196 */         j = this.sq.count - 1 - i;
/* 197 */         this.m = ("( " + (String)this.sq.date.get(j) + ", Fast%K[" + this.parm1 + ", " + this.parm2 + "]:" + this.df.format(this.fastK_parm1_parm2[j]) + "  Slow%D[" + this.parm3 + "]:" + this.df.format(this.slowD_parm3[j]) + " )");
/*     */ 
/* 199 */         this.mX = paramMouseEvent.getX();
/* 200 */         this.mY = paramMouseEvent.getY();
/* 201 */         repaint();
/* 202 */         return;
/*     */       }
/*     */ 
/* 206 */       this.m = "";
/*     */ 
/* 208 */       repaint();
/* 209 */       return;
/*     */     }
/*     */ 
/* 213 */     this.m = "";
/* 214 */     repaint();
/*     */   }
/*     */ 
/*     */   public void mouseDragged(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ 
/*     */   private void drawValues(Graphics2D paramGraphics2D)
/*     */   {
/* 227 */     paramGraphics2D.setPaint(Color.cyan);
/*     */ 
/* 229 */     if (this.mX + this.m.length() * 5 > 750.0F * this.xScale + 50.0F) {
/* 230 */       this.mX -= this.m.length() * 5;
/*     */     }
/* 232 */     paramGraphics2D.drawString(this.m, this.mX, this.mY);
/*     */   }
/*     */ 
/*     */   private void lowHigh_parm1Finder()
/*     */   {
/* 239 */     for (int i = this.parm1; i < this.sq.count; i++)
/*     */     {
/* 241 */       this.low_parm1[i] = ((Float)this.sq.low.get(i)).floatValue();
/* 242 */       this.high_parm1[i] = ((Float)this.sq.high.get(i)).floatValue();
/* 243 */       for (int j = i - 1; j >= i - (this.parm1 - 1); j--)
/*     */       {
/* 245 */         if (this.low_parm1[i] > ((Float)this.sq.low.get(j)).floatValue()) {
/* 246 */           this.low_parm1[i] = ((Float)this.sq.low.get(j)).floatValue();
/*     */         }
/* 248 */         if (this.high_parm1[i] < ((Float)this.sq.high.get(j)).floatValue())
/* 249 */           this.high_parm1[i] = ((Float)this.sq.high.get(j)).floatValue();
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   private void fastK_parm1_parm2Finder()
/*     */   {
/* 258 */     for (int i = 0; i < this.parm1 + this.parm2; i++) {
/* 259 */       this.fastK_parm1_parm2[i] = 0.0F;
/*     */     }
/* 261 */     float f1 = 0.0F;
/* 262 */     for (int j = this.parm1 + this.parm2; j > this.parm1; j--)
/*     */     {
/* 264 */       f1 += this.fastK_parm1[j];
/*     */     }
/*     */ 
/* 268 */     this.fastK_parm1_parm2[(this.parm1 + this.parm2)] = (f1 / this.parm2);
/*     */ 
/* 270 */     float f2 = 2.0F / (this.parm2 + 1);
/*     */ 
/* 272 */     for (int k = this.parm1 + this.parm2 + 1; k < this.sq.count; k++)
/*     */     {
/* 274 */       this.fastK_parm1_parm2[k] = (this.fastK_parm1[k] * f2 + this.fastK_parm1_parm2[(k - 1)] * (1.0F - f2));
/*     */     }
/*     */   }
/*     */ 
/*     */   private void slowD_parm3Finder()
/*     */   {
/* 283 */     for (int i = 0; i < this.parm1 + this.parm2 + this.parm3; i++) {
/* 284 */       this.slowD_parm3[i] = 0.0F;
/*     */     }
/* 286 */     float f1 = 0.0F;
/* 287 */     for (int j = this.parm1 + this.parm2 + this.parm3; j > this.parm1 + this.parm2; j--)
/*     */     {
/* 289 */       f1 += this.fastK_parm1_parm2[j];
/*     */     }
/*     */ 
/* 293 */     this.slowD_parm3[(this.parm1 + this.parm2 + this.parm3)] = (f1 / this.parm3);
/*     */ 
/* 295 */     float f2 = 2.0F / (this.parm3 + 1);
/*     */ 
/* 297 */     for (int k = this.parm1 + this.parm2 + this.parm3 + 1; k < this.sq.count; k++)
/*     */     {
/* 299 */       this.slowD_parm3[k] = (this.fastK_parm1_parm2[k] * f2 + this.slowD_parm3[(k - 1)] * (1.0F - f2));
/*     */     }
/*     */   }
/*     */ 
/*     */   private void fastK_parm1Finder()
/*     */   {
/* 308 */     for (int i = this.parm1; i < this.sq.count; i++)
/*     */     {
/* 310 */       this.fastK_parm1[i] = ((((Float)this.sq.close.get(i)).floatValue() - this.low_parm1[i]) / (this.high_parm1[i] - this.low_parm1[i]) * 100.0F);
/*     */     }
/*     */   }
/*     */ 
/*     */   public void updateParms(int paramInt1, int paramInt2, int paramInt3)
/*     */   {
/* 319 */     this.parm1 = paramInt1;
/* 320 */     this.parm2 = paramInt2;
/* 321 */     this.parm3 = paramInt3;
/*     */ 
/* 323 */     lowHigh_parm1Finder();
/* 324 */     fastK_parm1Finder();
/* 325 */     fastK_parm1_parm2Finder();
/* 326 */     slowD_parm3Finder();
/*     */   }
/*     */ 
/*     */   public Box getStochBox(boolean paramBoolean)
/*     */   {
/* 333 */     Box localBox = Box.createHorizontalBox();
/* 334 */     TitledBorder localTitledBorder = BorderFactory.createTitledBorder("Stochastic Oscillator");
/*     */ 
/* 336 */     this.parm1TF = new JTextField("" + this.parm1, 2);
/* 337 */     this.parm2TF = new JTextField("" + this.parm2, 2);
/* 338 */     this.parm3TF = new JTextField("" + this.parm3, 2);
/* 339 */     this.parm1TF.setFont(this.ssp10);
/* 340 */     this.parm2TF.setFont(this.ssp10);
/* 341 */     this.parm3TF.setFont(this.ssp10);
/* 342 */     this.parm1TF.setMaximumSize(new Dimension(25, 20));
/* 343 */     this.parm2TF.setMaximumSize(new Dimension(25, 20));
/* 344 */     this.parm3TF.setMaximumSize(new Dimension(25, 20));
/*     */ 
/* 346 */     JLabel localJLabel1 = new JLabel("Fast%K[");
/* 347 */     JLabel localJLabel2 = new JLabel(", ");
/* 348 */     JLabel localJLabel3 = new JLabel("] ,  Slow%D[");
/* 349 */     JLabel localJLabel4 = new JLabel("]     ");
/*     */ 
/* 351 */     localJLabel1.setFont(this.ssp10);
/* 352 */     localJLabel2.setFont(this.ssp10);
/* 353 */     localJLabel3.setFont(this.ssp10);
/* 354 */     localJLabel4.setFont(this.ssp10);
/*     */ 
/* 356 */     localBox.add(localJLabel1);
/* 357 */     localBox.add(this.parm1TF);
/* 358 */     localBox.add(localJLabel2);
/* 359 */     localBox.add(this.parm2TF);
/* 360 */     localBox.add(localJLabel3);
/* 361 */     localBox.add(this.parm3TF);
/* 362 */     localBox.add(localJLabel4);
/*     */ 
/* 364 */     localBox.add(Box.createHorizontalGlue());
/*     */ 
/* 366 */     if (paramBoolean) {
/* 367 */       localBox.setBorder(localTitledBorder);
/*     */     }
/* 369 */     return localBox;
/*     */   }
/*     */ 
/*     */   public void showChgParmDialog()
/*     */   {
/* 376 */     JFrame localJFrame = new JFrame();
/* 377 */     this.chgParmDialog = new JDialog(localJFrame, "Change Stochastic Parameters", true);
/* 378 */     Box localBox1 = Box.createVerticalBox();
/* 379 */     Box localBox2 = Box.createHorizontalBox();
/*     */ 
/* 381 */     this.chgParmOk = new JButton("OK");
/* 382 */     this.chgParmOk.setFont(this.ssp10);
/* 383 */     this.chgParmOk.setMargin(new Insets(1, 2, 1, 2));
/* 384 */     this.chgParmOk.addActionListener(this);
/*     */ 
/* 386 */     this.chgParmCancel = new JButton("Cancel");
/* 387 */     this.chgParmCancel.setFont(this.ssp10);
/* 388 */     this.chgParmCancel.setMargin(new Insets(1, 2, 1, 2));
/* 389 */     this.chgParmCancel.addActionListener(this);
/*     */ 
/* 391 */     this.defaultParms = new JButton("Default");
/* 392 */     this.defaultParms.setFont(this.ssp10);
/* 393 */     this.defaultParms.setMargin(new Insets(1, 2, 1, 2));
/* 394 */     this.defaultParms.setToolTipText("Reset to default parameters");
/* 395 */     this.defaultParms.addActionListener(this);
/*     */ 
/* 397 */     localBox2.add(Box.createHorizontalGlue());
/* 398 */     localBox2.add(this.chgParmOk);
/* 399 */     localBox2.add(Box.createHorizontalStrut(5));
/* 400 */     localBox2.add(this.chgParmCancel);
/* 401 */     localBox2.add(Box.createHorizontalStrut(5));
/* 402 */     localBox2.add(this.defaultParms);
/* 403 */     localBox2.add(Box.createHorizontalGlue());
/*     */ 
/* 405 */     localBox1.add(getStochBox(true));
/* 406 */     localBox1.add(localBox2);
/*     */ 
/* 408 */     this.chgParmDialog.getContentPane().add(localBox1);
/* 409 */     this.chgParmDialog.setSize(250, 100);
/* 410 */     this.chgParmDialog.setLocationRelativeTo(this.ep);
/* 411 */     this.chgParmDialog.setVisible(true);
/*     */   }
/*     */ 
/*     */   public boolean validateParm()
/*     */   {
/* 418 */     int i = this.parm1;
/* 419 */     int j = this.parm2;
/* 420 */     int k = this.parm3;
/*     */     try
/*     */     {
/* 424 */       i = Integer.parseInt(this.parm1TF.getText().trim());
/* 425 */       j = Integer.parseInt(this.parm2TF.getText().trim());
/* 426 */       k = Integer.parseInt(this.parm3TF.getText().trim());
/*     */     }
/*     */     catch (NumberFormatException localNumberFormatException)
/*     */     {
/* 432 */       JOptionPane.showMessageDialog(null, "Error in Stochastic parameter.Enter only numbers greater than 2.", null, 0);
/*     */ 
/* 435 */       this.parm1TF.setText("" + this.parm1);
/* 436 */       this.parm2TF.setText("" + this.parm2);
/* 437 */       this.parm3TF.setText("" + this.parm3);
/*     */ 
/* 439 */       return false;
/*     */     }
/*     */ 
/* 443 */     if ((i > 200) || (j > 200) || (k > 200))
/*     */     {
/* 445 */       JOptionPane.showMessageDialog(null, "Error in Stochastic parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 448 */       this.parm1TF.setText("" + this.parm1);
/* 449 */       this.parm2TF.setText("" + this.parm2);
/* 450 */       this.parm3TF.setText("" + this.parm3);
/*     */ 
/* 452 */       return false;
/*     */     }
/*     */ 
/* 456 */     if ((i < 2) || (j < 2) || (k < 2))
/*     */     {
/* 458 */       JOptionPane.showMessageDialog(null, "Error in Stochastic parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 461 */       this.parm1TF.setText("" + this.parm1);
/* 462 */       this.parm2TF.setText("" + this.parm2);
/* 463 */       this.parm3TF.setText("" + this.parm3);
/*     */ 
/* 465 */       return false;
/*     */     }
/*     */ 
/* 469 */     this.parm1 = i;
/* 470 */     this.parm2 = j;
/* 471 */     this.parm3 = k;
/*     */ 
/* 473 */     return true;
/*     */   }
/*     */ 
/*     */   public void actionPerformed(ActionEvent paramActionEvent)
/*     */   {
/* 480 */     if (paramActionEvent.getSource() == this.chgParmOk)
/*     */     {
/* 482 */       if (!validateParm()) {
/* 483 */         return;
/*     */       }
/* 485 */       redrawChart();
/* 486 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 490 */     if (paramActionEvent.getSource() == this.chgParmCancel)
/*     */     {
/* 492 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 496 */     if (paramActionEvent.getSource() == this.defaultParms)
/*     */     {
/* 498 */       setDefaultParms();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setDefaultParms()
/*     */   {
/* 507 */     this.parm1TF.setText("10");
/* 508 */     this.parm2TF.setText("5");
/* 509 */     this.parm3TF.setText("5");
/*     */   }
/*     */ 
/*     */   public void vZoom(boolean paramBoolean)
/*     */   {
/* 516 */     if (paramBoolean)
/* 517 */       this.yScale += 0.2F;
/* 518 */     else if (this.yScale >= 1.2F) {
/* 519 */       this.yScale -= 0.2F;
/*     */     }
/* 521 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void hZoom(boolean paramBoolean)
/*     */   {
/* 528 */     if (paramBoolean)
/* 529 */       this.xScale += 0.2F;
/* 530 */     else if (this.xScale >= 1.2F) {
/* 531 */       this.xScale -= 0.2F;
/*     */     }
/* 533 */     if (this.noOfDays == 150)
/* 534 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 536 */       this.stickWidth = (1.5D * this.xScale);
/* 537 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void resetZoom()
/*     */   {
/* 544 */     this.yScale = 1.0F;
/* 545 */     this.xScale = 1.0F;
/* 546 */     if (this.noOfDays == 150)
/* 547 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 549 */       this.stickWidth = (1.5D * this.xScale);
/* 550 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   protected void clear(Graphics paramGraphics)
/*     */   {
/* 557 */     super.paintComponent(paramGraphics);
/*     */   }
/*     */ 
/*     */   protected void paintComponent(Graphics paramGraphics)
/*     */   {
/* 564 */     clear(paramGraphics);
/* 565 */     Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
/* 566 */     drawChart(localGraphics2D);
/* 567 */     drawValues(localGraphics2D);
/*     */   }
/*     */ 
/*     */   private void drawChart(Graphics2D paramGraphics2D)
/*     */   {
/* 596 */     this.refY = 10.0D;
/* 597 */     this.refX = 50.0D;
/* 598 */     setFont(this.ssp10);
/* 599 */     String str = "Stochastic Oscillator";
/* 600 */     paramGraphics2D.setPaint(new Color(100, 240, 250));
/* 601 */     paramGraphics2D.drawString(str, 50, 10);
/*     */ 
/* 603 */     str = "Fast%K[" + this.parm1 + "," + this.parm2 + "]";
/* 604 */     paramGraphics2D.setPaint(new Color(50, 150, 255));
/* 605 */     paramGraphics2D.drawString(str, 155, 10);
/*     */ 
/* 607 */     str = "Slow%D[" + this.parm3 + "]";
/* 608 */     paramGraphics2D.setPaint(Color.magenta);
/* 609 */     paramGraphics2D.drawString(str, 225, 10);
/*     */ 
/* 612 */     this.refL1.setLine(50.0D, 10.0D, 50.0D, this.yScale * 100.0F + 10.0F);
/* 613 */     this.refL2.setLine(750.0F * this.xScale + 50.0F, 10.0D, 750.0F * this.xScale + 50.0F, this.yScale * 100.0F + 10.0F);
/* 614 */     paramGraphics2D.setPaint(Color.white);
/* 615 */     paramGraphics2D.draw(this.refL1);
/* 616 */     paramGraphics2D.draw(this.refL2);
/*     */ 
/* 618 */     for (int i = 0; i < 14; i++)
/*     */     {
/* 620 */       this.refX += 50.0F * this.xScale;
/* 621 */       this.gridY.setLine(this.refX, 10.0D, this.refX, this.yScale * 100.0F + 10.0F);
/* 622 */       paramGraphics2D.setPaint(Color.darkGray);
/* 623 */       paramGraphics2D.draw(this.gridY);
/*     */     }
int i;
/*     */ 
/* 627 */     for (i = 0; i < 11; i++)
/*     */     {
/* 629 */       this.yrefL1.setLine(50.0D, this.refY, 40.0D, this.refY);
/* 630 */       str = this.df.format(this.maxVal - (this.maxVal - this.minVal) / 10.0F * i);
/* 631 */       paramGraphics2D.setPaint(Color.lightGray);
/* 632 */       paramGraphics2D.drawString(str, 10, (int)this.refY);
/* 633 */       this.yrefL2.setLine(750.0F * this.xScale + 50.0F, this.refY, 750.0F * this.xScale + 60.0F, this.refY);
/*     */ 
/* 635 */       paramGraphics2D.drawString(str, (int)(750.0F * this.xScale + 53.0F), (int)this.refY);
/* 636 */       this.gridX.setLine(50.0D, this.refY, 750.0F * this.xScale + 50.0F, this.refY);
/* 637 */       paramGraphics2D.setPaint(Color.white);
/* 638 */       paramGraphics2D.draw(this.yrefL1);
/* 639 */       paramGraphics2D.draw(this.yrefL2);
/* 640 */       paramGraphics2D.setPaint(Color.darkGray);
/* 641 */       paramGraphics2D.draw(this.gridX);
/* 642 */       this.refY += 10.0F * this.yScale;
/*     */     }
/*     */ 
/* 646 */     this.yfactor = (this.yScale * 100.0F / (this.maxVal - this.minVal));
/* 647 */     this.startPointX = (750.0F * this.xScale + 50.0F - (this.stickWidth + 1.0F * this.xScale));
/* 648 */     this.dateRef = (this.sq.count - 1);
/* 649 */     this.daysRef = 1;
/*     */ 
/* 652 */     for (i = this.sq.count - 1; i > this.parm1 + this.parm2; i--)
/*     */     {
/* 654 */       if (this.daysRef == this.noOfDays)
/*     */         break;
/* 656 */       paramGraphics2D.setFont(this.ssp10);
/*     */ 
/* 659 */       if (i > this.parm1 + this.parm2)
/*     */       {
/* 661 */         this.p11Y = (this.yScale * 100.0F + 10.0F - (this.fastK_parm1_parm2[i] - this.minVal) * this.yfactor);
/* 662 */         this.p22Y = (this.yScale * 100.0F + 10.0F - (this.fastK_parm1_parm2[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 664 */         this.l2.setLine(this.startPointX, this.p11Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p22Y);
/* 665 */         paramGraphics2D.setPaint(new Color(50, 150, 255));
/* 666 */         paramGraphics2D.draw(this.l2);
/*     */       }
/*     */ 
/* 670 */       if (i > this.parm1 + this.parm2 + this.parm3)
/*     */       {
/* 672 */         this.p1Y = (this.yScale * 100.0F + 10.0F - (this.slowD_parm3[i] - this.minVal) * this.yfactor);
/* 673 */         this.p2Y = (this.yScale * 100.0F + 10.0F - (this.slowD_parm3[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 675 */         this.l1.setLine(this.startPointX, this.p1Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p2Y);
/* 676 */         paramGraphics2D.setPaint(Color.magenta);
/* 677 */         paramGraphics2D.draw(this.l1);
/*     */       }
/*     */ 
/* 681 */       if ((i > this.parm1 + this.parm2 + this.parm3) && (this.fastK_parm1_parm2[i] - this.slowD_parm3[i] >= 0.0F) && (this.fastK_parm1_parm2[(i - 1)] - this.slowD_parm3[(i - 1)] < 0.0F))
/*     */       {
/* 683 */         this.x1 = this.startPointX;
/* 684 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 685 */         this.y1 = this.p1Y;
/* 686 */         this.y2 = this.p2Y;
/* 687 */         this.u1 = this.x1;
/* 688 */         this.u2 = this.x2;
/* 689 */         this.v1 = this.p11Y;
/* 690 */         this.v2 = this.p22Y;
/*     */ 
/* 692 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 693 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 695 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 696 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 698 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 699 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 701 */         paramGraphics2D.setPaint(Color.green);
/* 702 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 703 */         this.lA.setLine(this.xi, this.yi - 5.0D, this.xi - 3.0D, this.yi);
/* 704 */         this.hA.setLine(this.xi, this.yi - 5.0D, this.xi + 3.0D, this.yi);
/* 705 */         paramGraphics2D.draw(this.uA);
/* 706 */         paramGraphics2D.draw(this.lA);
/* 707 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 711 */       if ((i > this.parm1 + this.parm2 + this.parm3) && (this.fastK_parm1_parm2[i] - this.slowD_parm3[i] < 0.0F) && (this.fastK_parm1_parm2[(i - 1)] - this.slowD_parm3[(i - 1)] > 0.0F))
/*     */       {
/* 713 */         this.x1 = this.startPointX;
/* 714 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 715 */         this.y1 = this.p1Y;
/* 716 */         this.y2 = this.p2Y;
/* 717 */         this.u1 = this.x1;
/* 718 */         this.u2 = this.x2;
/* 719 */         this.v1 = this.p11Y;
/* 720 */         this.v2 = this.p22Y;
/*     */ 
/* 722 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 723 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 725 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 726 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 728 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 729 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 731 */         paramGraphics2D.setPaint(Color.red);
/* 732 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 733 */         this.lA.setLine(this.xi, this.yi + 5.0D, this.xi - 3.0D, this.yi);
/* 734 */         this.hA.setLine(this.xi, this.yi + 5.0D, this.xi + 3.0D, this.yi);
/* 735 */         paramGraphics2D.draw(this.uA);
/* 736 */         paramGraphics2D.draw(this.lA);
/* 737 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 741 */       if (this.dateRef == i)
/*     */       {
/* 743 */         paramGraphics2D.setFont(this.ssp9);
/* 744 */         str = ((String)this.sq.date.get(i)).substring(0, 6);
/* 745 */         if (this.fastK_parm1_parm2[i] >= this.slowD_parm3[i])
/* 746 */           paramGraphics2D.setPaint(Color.green);
/*     */         else {
/* 748 */           paramGraphics2D.setPaint(Color.red);
/*     */         }
/* 750 */         paramGraphics2D.drawString(str, (int)this.startPointX, (int)(this.yScale * 100.0F + 20.0F));
/* 751 */         if (this.noOfDays == 150)
/* 752 */           this.dateRef -= 10;
/*     */         else
/* 754 */           this.dateRef -= 20;
/* 755 */         paramGraphics2D.setFont(this.ssp10);
/*     */       }
/*     */ 
/* 759 */       this.startPointX = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 760 */       this.daysRef += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   public static void main(String[] paramArrayOfString)
/*     */   {
/* 824 */     FileDownloader localFileDownloader = new FileDownloader();
/* 825 */     localFileDownloader.downloadFiles();
/* 826 */     SymQuotes localSymQuotes = new SymQuotes("WIPRO", localFileDownloader.datesToRead, 1, 1, "ns");
/*     */ 
/* 828 */     StochChart localStochChart = new StochChart(localSymQuotes, 10, 5, 5);
/*     */ 
/* 830 */     JFrame localJFrame = new JFrame("Test");
/* 831 */     localJFrame.setDefaultCloseOperation(3);
/* 832 */     localJFrame.getContentPane().add(localStochChart);
/* 833 */     localJFrame.pack();
/* 834 */     localJFrame.setSize(850, 175);
/* 835 */     localJFrame.setVisible(true);
/*     */   }
/*     */ 
/*     */   public class EastPanel extends JPanel
/*     */   {
/*     */     private JLabel title;
/*     */     private JLabel fastKL;
/*     */     private JLabel slowDL;
/*     */     private JLabel trendL;
/*     */     private ChartHelpButton chb;
/* 772 */     private Font valuesF = new Font("Sanserif", 0, 11);
/* 773 */     public Box buttonsPanel = Box.createHorizontalBox();
/*     */ 
/*     */     public EastPanel()
/*     */     {
/* 777 */       this.title = new JLabel("Stochastic Oscillator");
/* 778 */       this.fastKL = new JLabel("Fast%K[" + StochChart.this.parm1 + ", " + StochChart.this.parm2 + "]: " + StochChart.this.df.format(StochChart.this.fastK_parm1_parm2[(StochChart.this.sq.count - 1)]));
/* 779 */       this.slowDL = new JLabel("Slow%D[" + StochChart.this.parm3 + "]: " + StochChart.this.df.format(StochChart.this.slowD_parm3[(StochChart.this.sq.count - 1)]));
/* 780 */       this.trendL = new JLabel("Trend: " + StochChart.this.trend);
/* 781 */       this.chb = new ChartHelpButton("http://www.profitindicators.com/home/indicators/stoch.htm", "Help on Stochastic Oscillator");
/*     */ 
/* 783 */       this.chb.setFont(this.valuesF);
/*     */ 
/* 785 */       this.fastKL.setFont(this.valuesF);
/* 786 */       this.slowDL.setFont(this.valuesF);
/* 787 */       this.trendL.setFont(this.valuesF);
/*     */ 
/* 789 */       this.buttonsPanel.add(this.chb);
/* 790 */       this.buttonsPanel.add(Box.createHorizontalStrut(2));
/* 791 */       this.buttonsPanel.setAlignmentX(0.0F);
/*     */ 
/* 793 */       setLayout(new BoxLayout(this, 3));
/*     */ 
/* 795 */       add(this.title);
/* 796 */       add(this.fastKL);
/* 797 */       add(this.slowDL);
/* 798 */       add(new JLabel(" "));
/* 799 */       add(this.trendL);
/* 800 */       add(this.buttonsPanel);
/* 801 */       add(Box.createVerticalGlue());
/*     */ 
/* 803 */       setBackground(new Color(243, 245, 252));
/*     */     }
/*     */ 
/*     */     public void updateValues()
/*     */     {
/* 810 */       this.fastKL.setText("Fast%K[" + StochChart.this.parm1 + ", " + StochChart.this.parm2 + "]: " + StochChart.this.df.format(StochChart.this.fastK_parm1_parm2[(StochChart.this.sq.count - 1)]));
/* 811 */       this.slowDL.setText("Slow%D[" + StochChart.this.parm3 + "]: " + StochChart.this.df.format(StochChart.this.slowD_parm3[(StochChart.this.sq.count - 1)]));
/* 812 */       this.trendL.setText("Trend: " + StochChart.this.trend);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Deebak\Downloads\profitindicatorsv2-05.jar
 * Qualified Name:     StochChart
 * JD-Core Version:    0.6.0
 */